﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using FMPCore.Interfaces;

namespace Client
{
    /// <summary>
    /// Interaction logic for winAddUser.xaml
    /// </summary>
    public partial class winAddContact : Window
    {
        IMessage m_messageProxy;
        string m_currentUser;

        public winAddContact(IMessage messageProxy, string currentUser)
        {
            m_messageProxy = messageProxy;
            m_currentUser = currentUser;
            InitializeComponent();
        }

        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(txtContactName.Text))
            {
                if(m_messageProxy.UserExist(txtContactName.Text))
                {
                    this.DialogResult = m_messageProxy.AddContact(m_currentUser, txtContactName.Text);
                }
                else
                {
                    MessageBox.Show(string.Format("The username: {0}, does not exist.", txtContactName.Text));
                }
            }
            else
            {
                MessageBox.Show("Contact name cannot be blank.");
            }
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = null;
        }
    }
}
